<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Nginx 日志配置完全指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        
        .code-block {
            background: #1e293b;
            border-radius: 12px;
            overflow: hidden;
            position: relative;
        }
        
        .code-header {
            background: #334155;
            padding: 8px 16px;
            font-size: 12px;
            color: #94a3b8;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        
        pre {
            margin: 0;
            padding: 20px;
            overflow-x: auto;
        }
        
        code {
            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
            color: #e2e8f0;
            line-height: 1.6;
        }
        
        .inline-code {
            background: #e0e7ff;
            color: #4338ca;
            padding: 2px 6px;
            border-radius: 4px;
            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
            font-size: 0.9em;
        }
        
        .section-divider {
            height: 2px;
            background: linear-gradient(to right, transparent, #e0e7ff, transparent);
            margin: 3rem 0;
        }
        
        .floating-icon {
            animation: float 3s ease-in-out infinite;
        }
        
        @keyframes float {
            0%, 100% { transform: translateY(0px); }
            50% { transform: translateY(-10px); }
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        
        .feature-card {
            background: white;
            border-radius: 16px;
            padding: 2rem;
            position: relative;
            overflow: hidden;
        }
        
        .feature-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
        }
        
        .log-level {
            display: inline-block;
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 0.875rem;
            font-weight: 500;
            margin: 0 4px;
        }
        
        .level-debug { background: #dbeafe; color: #1e40af; }
        .level-info { background: #d1fae5; color: #065f46; }
        .level-warn { background: #fef3c7; color: #92400e; }
        .level-error { background: #fee2e2; color: #991b1b; }
        .level-crit { background: #fce7f3; color: #9f1239; }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white">
        <div class="container mx-auto px-6 py-20">
            <div class="max-w-4xl mx-auto text-center">
                <div class="floating-icon inline-block mb-6">
                    <i class="fas fa-file-alt text-6xl opacity-90"></i>
                </div>
                <h1 class="text-5xl font-bold mb-6">Nginx 日志配置完全指南</h1>
                <p class="text-xl opacity-90 leading-relaxed">
                    掌握 Nginx 日志系统，让服务器监控和调试变得轻而易举
                </p>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="container mx-auto px-6 py-12 max-w-6xl">
        <!-- Introduction Card -->
        <div class="feature-card card-hover mb-8">
            <div class="flex items-start">
                <div class="mr-4 text-purple-600">
                    <i class="fas fa-info-circle text-2xl"></i>
                </div>
                <div class="flex-1">
                    <h2 class="text-2xl font-bold mb-4 text-gray-800">为什么日志配置如此重要？</h2>
                    <p class="text-gray-600 leading-relaxed text-lg">
                        在 Nginx 中，日志记录和日志格式配置是非常重要的，可以帮助我们监控和调试服务器的状态。
                        Nginx 提供了灵活的日志记录功能，包括访问日志和错误日志，让您能够全面掌握服务器的运行状况。
                    </p>
                </div>
            </div>
        </div>

        <!-- Visualization -->
        <div class="feature-card mb-8">
            <h3 class="text-xl font-bold mb-4 text-gray-800 text-center">
                <i class="fas fa-sitemap mr-2 text-purple-600"></i>Nginx 日志系统架构
            </h3>
            <div class="mermaid">
                graph TD
                    A[Nginx 日志系统] --> B[访问日志]
                    A --> C[错误日志]
                    B --> D[日志格式定义]
                    B --> E[日志路径配置]
                    B --> F[条件日志记录]
                    C --> G[错误级别设置]
                    C --> H[错误日志路径]
                    D --> I[预定义格式]
                    D --> J[自定义格式]
                    
                    style A fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                    style B fill:#a78bfa,stroke:#fff,stroke-width:2px,color:#fff
                    style C fill:#a78bfa,stroke:#fff,stroke-width:2px,color:#fff
            </div>
        </div>

        <!-- Section 1: Access Log -->
        <div class="mb-12">
            <h2 class="text-3xl font-bold mb-6 text-gray-800 flex items-center">
                <span class="text-purple-600 mr-3">1.</span>
                <i class="fas fa-chart-line mr-3 text-purple-600"></i>
                配置访问日志
            </h2>
            
            <div class="feature-card card-hover">
                <p class="text-gray-600 mb-6 text-lg leading-relaxed">
                    访问日志记录了所有对服务器的请求。我们可以通过 <span class="inline-code">access_log</span> 
                    指令来配置访问日志的路径和格式。
                </p>
                
                <div class="code-block mb-6">
                    <div class="code-header">
                        <span><i class="fas fa-code mr-2"></i>nginx.conf</span>
                        <span class="text-xs">访问日志配置示例</span>
                    </div>
                    <pre><code>http {
    # 定义日志格式
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    # 配置访问日志文件路径及使用的日志格式
    access_log /var/log/nginx/access.log main;

    # 其他配置...
}</code></pre>
                </div>
                
                <div class="bg-purple-50 rounded-lg p-6">
                    <h4 class="font-bold text-purple-800 mb-3">
                        <i class="fas fa-lightbulb mr-2"></i>配置解释
                    </h4>
                    <ul class="space-y-3 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                            <div>
                                <span class="inline-code">log_format</span> 指令定义了日志的格式。
                                上例中定义了名为 <span class="inline-code">main</span> 的日志格式，
                                其中包含了客户端 IP 地址、时间、本次请求的内容、响应状态码、用户代理等信息。
                            </div>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                            <div>
                                <span class="inline-code">access_log</span> 指令配置了访问日志的存储路径 
                                <span class="inline-code">/var/log/nginx/access.log</span>，
                                并指定使用 <span class="inline-code">main</span> 格式。
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>

        <div class="section-divider"></div>

        <!-- Section 2: Error Log -->
        <div class="mb-12">
            <h2 class="text-3xl font-bold mb-6 text-gray-800 flex items-center">
                <span class="text-purple-600 mr-3">2.</span>
                <i class="fas fa-exclamation-triangle mr-3 text-purple-600"></i>
                配置错误日志
            </h2>
            
            <div class="feature-card card-hover">
                <p class="text-gray-600 mb-6 text-lg leading-relaxed">
                    错误日志记录了服务器的错误信息。我们可以通过 <span class="inline-code">error_log</span> 
                    指令来配置错误日志的路径和日志级别。
                </p>
                
                <div class="code-block mb-6">
                    <div class="code-header">
                        <span><i class="fas fa-code mr-2"></i>nginx.conf</span>
                        <span class="text-xs">错误日志配置示例</span>
                    </div>
                    <pre><code>http {
    # 配置错误日志文件路径及日志级别
    error_log /var/log/nginx/error.log warn;

    # 其他配置...
}</code></pre>
                </div>
                
                <div class="bg-purple-50 rounded-lg p-6 mb-6">
                    <h4 class="font-bold text-purple-800 mb-3">
                        <i class="fas fa-lightbulb mr-2"></i>配置解释
                    </h4>
                    <p class="text-gray-700">
                        <span class="inline-code">error_log</span> 指令配置了错误日志的存储路径 
                        <span class="inline-code">/var/log/nginx/error.log</span>，
                        并指定日志级别为 <span class="inline-code">warn</span>。
                    </p>
                </div>
                
                <!-- Log Levels -->
                <div class="bg-gray-50 rounded-lg p-6">
                    <h4 class="font-bold text-gray-800 mb-4">
                        <i class="fas fa-layer-group mr-2 text-purple-600"></i>日志级别详解
                    </h4>
                    <div class="grid grid-cols-2 md:grid-cols-4 gap-3">
                        <div class="text-center">
                            <span class="log-level level-debug">debug</span>
                            <p class="text-sm text-gray-600 mt-2">调试信息</p>
                        </div>
                        <div class="text-center">
                            <span class="log-level level-info">info</span>
                            <p class="text-sm text-gray-600 mt-2">一般信息</p>
                        </div>
                        <div class="text-center">
                            <span class="log-level level-info">notice</span>
                            <p class="text-sm text-gray-600 mt-2">正常但重要</p>
                        </div>
                        <div class="text-center">
                            <span class="log-level level-warn">warn</span>
                            <p class="text-sm text-gray-600 mt-2">警告信息</p>
                        </div>
                        <div class="text-center">
                            <span class="log-level level-error">error</span>
                            <p class="text-sm text-gray-600 mt-2">错误信息</p>
                        </div>
                        <div class="text-center">
                            <span class="log-level level-crit">crit</span>
                            <p class="text-sm text-gray-600 mt-2">严重问题</p>
                        </div>
                        <div class="text-center">
                            <span class="log-level level-crit">alert</span>
                            <p class="text-sm text-gray-600 mt-2">必须立即处理</p>
                        </div>
                        <div class="text-center">
                            <span class="log-level level-error">emerg</span>
                            <p class="text-